// var i;
// exports._Manager = void 0;
// var $pPSDK_Config = require("./AL_Framework_AL_SDK_CONFIG");
// var $alert = require("./AL_Framework_Alert");
// var $loading = require("./AL_Framework_Loading");
// var $tips = require("./AL_Framework_Tips");
// var $uILoading = require("./AL_Framework_UI_Loading");
// var $sDKAdapter = require("./AL_Framework_SDK_Adapter");
// var $sDKHelper = require("./AL_Framework_SDK_Helper");
// var $subGame = require("./AL_Framework_Sub_Game");
// var $framework = require("./AL_Framework_Framework");
// var $settingStorage = require("./AL_Framework_Setting_Storage");
// var $macros = require("./AL_Framework_Macros");
// var m = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.logTag = "[AL_Framework_Application]: ";
//         t.version = "2022.5.11";
//         t._enterBackgroundTime = 0;
//         return t;
//     }
//     __extends(t, e);
//     Object.defineProperty(t.prototype, "shifou_yanchi_shifang_ziyuan", {
//         get: function () {
//             return !0;
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "tips", {
//         get: function () {
//             return y($tips.default);
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "loading", {
//         get: function () {
//             return y($loading.default);
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "alert", {
//         get: function () {
//             return y($alert.default);
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "ui_Loading", {
//         get: function () {
//             return y($uILoading.default);
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "settingStorage", {
//         get: function () {
//             return this.localManager.huoqu_cunchu_lei($settingStorage.default);
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "sdkHelper", {
//         get: function () {
//             return y($sDKHelper.default);
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "sdkAdapter", {
//         get: function () {
//             return y($sDKAdapter.AL_Framework_SDK_Adapter);
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "subGame", {
//         get: function () {
//             return $subGame.AL_Framework_Sub_Game;
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     t.prototype.enter = function () {
//         e.prototype.enter.call(this);
//         this.updateManager.hotUpdateUrl = $pPSDK_Config.Config.HOT_UPDATE_URL;
//         this.updateManager.hotUpdateUrlVersion = $pPSDK_Config.Config.HOT_UPDATE_URL_VERSION;
//         this.updateManager.mainBundles = $pPSDK_Config.Config.MIAN_PACK_INCLUDE;
//         this.updateManager.is_skip_check_update = $pPSDK_Config.Config.is_skip_check_update;
//         this.localManager.register("framework");
//         this.languageManager.zhuceYuyanbao("framework", $macros.Macro.BUNDLE_RESOURCES, "HUA/framework/common");
//     };
//     t.prototype.init = function (e) {
//         if (void 0 === e) {
//             e = {};
//         }
//         if (e.language) {
//             this.languageManager.shezhiYuyan(e.language);
//         }
//         Promise.all([this.loading.init(), this.tips.init(), this.alert.init()]).then(function () {
//             if (e.onCompleted) {
//                 e.onCompleted();
//             }
//         });
//     };
//     t.prototype.on = function (e, t, o, i) {
//         if (void 0 === e) {
//             e = null;
//         }
//         if (void 0 === t) {
//             t = null;
//         }
//         if (void 0 === o) {
//             o = null;
//         }
//         if (void 0 === i) {
//             i = !1;
//         }
//         this.eventCenter.on(e, t, o, i);
//     };
//     t.prototype.off = function () {
//         var e;
//         var t = [];
//         for (var o = 0; o < arguments.length; o++) {
//             t[o] = arguments[o];
//         }
//         (e = this.eventCenter).off.apply(e, t);
//     };
//     t.prototype.emit = function (e, t, o) {
//         if (void 0 === o) {
//             o = !1;
//         }
//         this.eventCenter.emit(e, t, o);
//     };
//     Object.defineProperty(t.prototype, "yinyue_kaiguan_zhuangtai", {
//         get: function () {
//             return this.settingStorage.yinyue_kaiguan_zhuangtai;
//         },
//         set: function (e) {
//             this.settingStorage.yinyue_kaiguan_zhuangtai = e;
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "yinxiao_kaiguan_zhuangtai", {
//         get: function () {
//             return this.settingStorage.yinxiao_kaiguan_zhuangtai;
//         },
//         set: function (e) {
//             this.settingStorage.yinxiao_kaiguan_zhuangtai = e;
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     Object.defineProperty(t.prototype, "zhendong_zhuangtai", {
//         get: function () {
//             return this.settingStorage.zhendong_zhuangtai;
//         },
//         set: function (e) {
//             this.settingStorage.zhendong_zhuangtai = e;
//         },
//         enumerable: !1,
//         configurable: !0
//     });
//     t.prototype.playMusic = function (e, t, o) {
//         if (void 0 === t) {
//             t = $macros.Macro.BUNDLE_RESOURCES;
//         }
//         if (void 0 === o) {
//             o = {};
//         }
//         return this.audioManager.playMusic(e, t, o);
//     };
//     t.prototype.bofang_yinxiao = function (e, t, o) {
//         if (void 0 === o) {
//             o = {};
//         }
//         return this.audioManager.bofang_yinxiao(e, t, o);
//     };
//     t.prototype.stopMusic = function () {
//         this.audioManager.stopMusic();
//     };
//     t.prototype.vibrate = function (e) {
//         if (void 0 === e) {
//             e = !1;
//         }
//         this.sdkHelper.vibrate(e);
//     };
//     t.prototype.showLoading = function (e) {
//         if (void 0 === e) {
//             e = {};
//         }
//         this.loading.show(e);
//     };
//     t.prototype.hideLoading = function () {
//         this.loading.hide();
//     };
//     t.prototype.showToast = function (e) {
//         this.tips.show(e);
//     };
//     t.prototype.xianshi_tanchuang_tishi = function (e) {
//         this.alert.show(e);
//     };
//     t.prototype.jinru_houtai = function () {
//         this._enterBackgroundTime = Date.now();
//         Log.d("[MainController]", "jinru_houtai " + this._enterBackgroundTime);
//         this.eventCenter.emit($macros.Macro.ENTER_BACKGROUND, this._enterBackgroundTime);
//     };
//     t.prototype.jinru_qiantai = function () {
//         var e = Date.now();
//         var t = e - this._enterBackgroundTime;
//         Log.d("[MainController]", "jinru_qiantai " + e + " background total time : " + t);
//         this.eventCenter.emit($macros.Macro.ENTER_FORGEGROUND, t);
//     };
//     return t;
// })($framework.AL_Framework_Framework);

// function y(e) {
//     return e.Instance();
// }
// exports._Manager = m;
// window.getSingleton = y;
// var _ = new m();
// _.logger.level = $pPSDK_Config.Config.LogLV;
// window.Manager = window.AL_APP_SDK_MANAGER = _;
// _.enter();


/**
 * @Author: jdk
 * @Version: 0.1
 * @Language: 中文
 * @Description: 这个角色会将用户输入的代码，优化成性能更好，可读性更强的新代码。
 */

exports._Manager = void 0;
const AL_Framework_AL_SDK_CONFIG = require("./AL_Framework_AL_SDK_CONFIG");
const AL_Framework_Alert = require("./AL_Framework_Alert");
const AL_Framework_Loading = require("./AL_Framework_Loading");
const AL_Framework_Tips = require("./AL_Framework_Tips");
const AL_Framework_UI_Loading = require("./AL_Framework_UI_Loading");
const AL_Framework_SDK_Adapter = require("./AL_Framework_SDK_Adapter");
const AL_Framework_SDK_Helper = require("./AL_Framework_SDK_Helper");
const AL_Framework_Sub_Game = require("./AL_Framework_Sub_Game");
const AL_Framework_Framework = require("./AL_Framework_Framework");
const AL_Framework_Setting_Storage = require("./AL_Framework_Setting_Storage");
const AL_Framework_Macros = require("./AL_Framework_Macros");

/**
 * @class AL_Framework_Application
 * @extends AL_Framework_Framework
 * @description 主应用类，处理初始化、事件绑定等功能。
 */
class AL_Framework_Application extends AL_Framework_Framework.AL_Framework_Framework {
    constructor() {
        super();
        this.logTag = "[AL_Framework_Application]: ";
        this.version = "2025.01.01";
        this._enterBackgroundTime = 0;
    }

    /**
     * @property {boolean} shifou_yanchi_shifang_ziyuan
     * @description 判断是否需要延迟释放资源
     */
    get shifou_yanchi_shifang_ziyuan() {
        return true;
    }

    /**
     * @property {AL_Framework_Tips} tips
     * @description 获取 AL_Framework_Tips 实例
     */
    get tips() {
        return getInstance(AL_Framework_Tips.default);
    }

    /**
     * @property {AL_Framework_Loading} loading
     * @description 获取 AL_Framework_Loading 实例
     */
    get loading() {
        return getInstance(AL_Framework_Loading.default);
    }

    /**
     * @property {AL_Framework_Alert} alert
     * @description 获取 AL_Framework_Alert 实例
     */
    get alert() {
        return getInstance(AL_Framework_Alert.default);
    }

    /**
     * @property {AL_Framework_UI_Loading} uiLoading
     * @description 获取 AL_Framework_UI_Loading 实例
     */
    get uiLoading() {
        return getInstance(AL_Framework_UI_Loading.default);
    }

    /**
     * @property {AL_Framework_Setting_Storage} settingStorage
     * @description 获取 AL_Framework_Setting_Storage 实例
     */
    get settingStorage() {
        return this.localManager.huoqu_cunchu_lei(AL_Framework_Setting_Storage.default);
    }

    /**
     * @property {AL_Framework_SDK_Helper} sdkHelper
     * @description 获取 AL_Framework_SDK_Helper 实例
     */
    get sdkHelper() {
        return getInstance(AL_Framework_SDK_Helper.default);
    }

    /**
     * @property {AL_Framework_SDK_Adapter} sdkAdapter
     * @description 获取 AL_Framework_SDK_Adapter 实例
     */
    get sdkAdapter() {
        return getInstance(AL_Framework_SDK_Adapter.AL_Framework_SDK_Adapter);
    }

    /**
     * @property {AL_Framework_Sub_Game} subGame
     * @description 获取 AL_Framework_Sub_Game 实例
     */
    get subGame() {
        return AL_Framework_Sub_Game.AL_Framework_Sub_Game;
    }

    /**
     * @method enter
     * @description 进入应用主界面
     */
    enter() {
        super.enter();
        // this.updateManager.hotUpdateUrl = AL_Framework_AL_SDK_CONFIG.Config.HOT_UPDATE_URL;
        // this.updateManager.hotUpdateUrlVersion = AL_Framework_AL_SDK_CONFIG.Config.HOT_UPDATE_URL_VERSION;
        // this.updateManager.mainBundles = AL_Framework_AL_SDK_CONFIG.Config.MIAN_PACK_INCLUDE;
        // this.updateManager.is_skip_check_update = AL_Framework_AL_SDK_CONFIG.Config.is_skip_check_update;
        this.localManager.register("framework");
        this.languageManager.zhuceYuyanbao("framework", AL_Framework_Macros.Macro.BUNDLE_RESOURCES, "HUA/framework/common");
    }

    /**
     * @method init
     * @param {Object} config - 初始化配置
     * @description 初始化应用
     */
    init(config = {}) {
        if (config.language) {
            this.languageManager.shezhiYuyan(config.language);
        }
        Promise.all([this.loading.init(), this.tips.init(), this.alert.init()]).then(() => {
            if (config.onCompleted) {
                config.onCompleted();
            }
        });
    }

    /**
     * @method on
     * @param {string} event - 事件类型
     * @param {Function} handler - 事件处理函数
     * @param {Object} context - 事件处理上下文
     * @param {boolean} once - 是否只触发一次
     * @description 绑定事件
     */
    on(event = null, handler = null, context = null, once = false) {
        this.eventCenter.on(event, handler, context, once);
    }

    /**
     * @method off
     * @description 解绑事件
     */
    off() {
        this.eventCenter.off.apply(this.eventCenter, arguments);
    }

    /**
     * @method emit
     * @param {string} event - 事件类型
     * @param {Object} data - 事件数据
     * @param {boolean} bubbles - 是否冒泡
     * @description 触发事件
     */
    emit(event, data, bubbles = false) {
        this.eventCenter.emit(event, data, bubbles);
    }

    /**
     * @property {boolean} yinyue_kaiguan_zhuangtai
     * @description 获取或设置音乐状态
     */
    get yinyue_kaiguan_zhuangtai() {
        return this.settingStorage.yinyue_kaiguan_zhuangtai;
    }
    set yinyue_kaiguan_zhuangtai(state) {
        this.settingStorage.yinyue_kaiguan_zhuangtai = state;
    }

    /**
     * @property {boolean} yinxiao_kaiguan_zhuangtai
     * @description 获取或设置音效状态
     */
    get yinxiao_kaiguan_zhuangtai() {
        return this.settingStorage.yinxiao_kaiguan_zhuangtai;
    }
    set yinxiao_kaiguan_zhuangtai(state) {
        this.settingStorage.yinxiao_kaiguan_zhuangtai = state;
    }

    /**
     * @property {boolean} zhendong_zhuangtai
     * @description 获取或设置震动状态
     */
    get zhendong_zhuangtai() {
        return this.settingStorage.zhendong_zhuangtai;
    }
    set zhendong_zhuangtai(state) {
        this.settingStorage.zhendong_zhuangtai = state;
    }

    /**
     * @method playMusic
     * @param {string} name - 音乐名称
     * @param {string} bundle - 资源包（默认值：Macros.Macro.BUNDLE_RESOURCES）
     * @param {Object} options - 音乐播放选项
     * @description 播放音乐
     * @returns {Promise}
     */
    playMusic(name, bundle = AL_Framework_Macros.Macro.BUNDLE_RESOURCES, options = {}) {
        return this.audioManager.playMusic(name, bundle, options);
    }

    /**
     * @method bofang_yinxiao
     * @param {string} name - 音效名称
     * @param {string} bundle - 资源包
     * @param {Object} options - 音效播放选项
     * @description 播放音效
     * @returns {Promise}
     */
    bofang_yinxiao(name, bundle, options = {}) {
        return this.audioManager.bofang_yinxiao(name, bundle, options);
    }

    /**
     * @method stopMusic
     * @description 停止音乐
     */
    stopMusic() {
        this.audioManager.stopMusic();
    }

    /**
     * @method vibrate
     * @param {boolean} isLong - 是否长震动
     * @description 触发震动
     */
    vibrate(isLong = false) {
        this.sdkHelper.vibrate(isLong);
    }

    /**
     * @method showLoading
     * @param {Object} options - 加载选项
     * @description 显示加载动画
     */
    showLoading(options = {}) {
        this.loading.show(options);
    }

    /**
     * @method hideLoading
     * @description 隐藏加载动画
     */
    hideLoading() {
        this.loading.hide();
    }

    /**
     * @method showToast
     * @param {Object} options - 提示选项
     * @description 显示提示信息
     */
    showToast(options) {
        this.tips.show(options);
    }

    /**
     * @method xianshi_tanchuang_tishi
     * @param {Object} options - 警告选项
     * @description 显示警告信息
     */
    xianshi_tanchuang_tishi(options) {
        this.alert.show(options);
    }

    /**
     * @method jinru_houtai
     * @description 进入后台
     */
    jinru_houtai() {
        this._enterBackgroundTime = Date.now();
        console.log("[MainController]", "jinru_houtai " + this._enterBackgroundTime);
        this.eventCenter.emit(AL_Framework_Macros.Macro.ENTER_BACKGROUND, this._enterBackgroundTime);
    }

    /**
     * @method jinru_qiantai
     * @description 进入前台
     */
    jinru_qiantai() {
        const currentTime = Date.now();
        const totalTimeInBackground = currentTime - this._enterBackgroundTime;
        console.log("[MainController]", "jinru_qiantai " + currentTime + " background total time: " + totalTimeInBackground);
        this.eventCenter.emit(AL_Framework_Macros.Macro.ENTER_FORGEGROUND, totalTimeInBackground);
    }
}

/**
 * @function getInstance
 * @param {Object} moduleClass - 模块实例
 * @description 获取模块的单例
 * @returns {Object} 单例对象
 */
function getInstance(moduleClass) {
    return moduleClass.Instance();
}

exports._Manager = AL_Framework_Application;
window.getSingleton = getInstance;
const manager = new AL_Framework_Application();
manager.logger.level = AL_Framework_AL_SDK_CONFIG.Config.LogLV;
window.Manager = window.AL_APP_SDK_MANAGER = manager;
manager.enter();
